# coding:utf-8
# 作者：理想国真恵玩
import pandas as pd

df = pd.DataFrame({
    "month": [1, 3, 5, 7],
    "year": [2018, 2019, 2020, 2021],
    "sale": [500, 1000, 800, 1200]
})
print(df)

# 将单列设置为索引
print('-' * 33)
df1 = df.set_index('year')
print(df)

# 将多列设置为索引
print('-' * 33)
df2 = df.set_index(['year', 'month'])
print(df2)
